#利用map批量检测用户名是否符合规范=> username符合规范, username不符合规范
#• 只能包含数据、字母、下划线，不以数字开头，长度在6-18之间
#filter把合法的用户名显示出来
# import re
# import string
#
# def func01(x):
#     lst = re.findall(r"[^0-9a-zA-Z_]",x)
#     if not lst and x[0] not in string.digits and 6 < len(x) < 18:
#         return f"{x}符合规范"
#     else:
#         return f"{x}不符合规范"
# result = map(func01,["66username"])
# print(''.join(list(result)))
#
#
# #匿名函数+reduce实现 1*2*3*...*n
# from functools import reduce
# print(reduce(lambda x,y:x*y,range(1,6)))
#
# #filter函数:找出[1-100]能被3整除的数
# result = filter(lambda x:x%3==0,range(1,101))
# print(list(result))
#
# #map函数:求list[1-10]各项的平方
# result = map(lambda x:x*x,range(1,11))
# print(list(result))
#
# #将列表[1,4,5,9] 转换成 '1459'的字
# lst = [1,4,5,9]
# print(reduce(lambda x,y:str(x)+str(y),lst))







# 有以下列表：list1=[7, -8, 5, 4, 0, -2, -5]
# 正数在前负数在后
# 整数从小到大
# 负数从大到小
##第一种方法，要考虑好几种情况，不如第二种好
# lst1=[7, -8, 5, 4, 0, -2, -5,100,200,-200]
# # lst1 = [-1,-3,0,-2]
# # lst1 = [-2,-3,-1]
# # lst1 = [0,-2,-3,-1]
# number = lst1[0]
# for i in lst1:
#     if i > number and i > 0:
#         number = i
#     elif i > number and i == 0:
#         number = 1
#     elif i > number and i < 0:
#         number = 1
# if number <= 0:
#     number = 1
#
# print(sorted(lst1, key=lambda x: x*(-number)+number+1 if x <= 0 else x))

#第二种方法
# def func1(x):
#     result1 = list(filter(lambda i:i>0,x))
#     result2 = list(filter(lambda i:i<=0,x))
#     result1.sort()
#     result2.sort(reverse=True)
#     result = result1 + result2
#     print(result)
# lst1=[7, -8, 5, 4, 0, -2, -5]
# func1(lst1)






# 这是一个字符串排序，排序规则：小写<大写<奇数<偶数
# s ='asdf234GDSdsf23' #排序:小写-大写-奇数-偶数
# 原理：先比较元组的第一个值，FALSE
# import string
#
# dic = {}
# k = 1
# for i in string.ascii_lowercase+string.ascii_uppercase+"13579"+"02468":
#     dic[i] = k
#     k += 1
# s ='asdf234GDSdsf23'
# print("".join(sorted(s,key=lambda x:dic[x])))
#
#
# 
#
#
#
# dic = {}
# for i in string.ascii_lowercase:
#     dic[i] = 1
# for i in string.ascii_uppercase:
#     dic[i] = 2
# for i in "13579":
#     dic[i] = 3
# for i in "02468":
#     dic[i] = 4
# print("".join(sorted(s,key=lambda x:dic[x])))














